package com.situ.store.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.situ.store.entity.Goods;
import com.situ.store.service.GoodsService;
import com.situ.store.service.OrderService;
import com.situ.store.service.impl.GoodsServiceImpl;
import com.situ.store.service.impl.OrderServiceImpl;
import com.situ.store.util.BaseController;
import com.situ.store.vo.LayuiTableVO;
import com.situ.store.vo.OrderVO;

@WebServlet("/order")
public class OrderController extends BaseController {

	private static final long serialVersionUID = 1L;

	OrderService ser = new OrderServiceImpl();

	// 单据主页
	public void page(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.getRequestDispatcher("/WEB-INF/order.jsp").forward(req, resp);
	}

	// 查询单据信息
	public LayuiTableVO orderList(Integer page, Integer limit, String keyword, String date) {
		return ser.orderList(page, limit, keyword, date);
	}

	public List<Goods> goodsList() throws IOException {
		GoodsService ser = new GoodsServiceImpl();
		return ser.selectName();
	}
	
	public OrderVO edit(Integer id) {
		return ser.selectById(id);
	}

	public void save(OrderVO o, HttpSession session) {
		ser.save(o, session);
	}

	public void del(Integer id) {
		ser.del(id);
	}

	public LayuiTableVO sum(String year, String month, String day) {
		return ser.sum(year, month, day);
	}

}
